{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.datasets import mnist\n",
    "from keras.layers import Flatten, Conv2D, MaxPool2D, Dense, Input,AveragePooling2D,Reshape,Activation,Dropout\n",
    "from keras.models import Sequential, Model\n",
    "from keras.optimizers import SGD\n",
    "from keras.utils import plot_model, to_categorical\n",
    "\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(60000, 28, 28)\n",
      "(10000, 28, 28)\n"
     ]
    }
   ],
   "source": [
    "(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
    "#数据变成TensorFow为Backend的形式\n",
    "print (x_train.shape)\n",
    "print (x_test.shape)\n",
    "x_train=x_train.reshape(60000,28,28,1)\n",
    "x_test=x_test.reshape(10000,28,28,1)\n",
    "#把标签变成one-hot编码的形式\n",
    "y_train=to_categorical(y_train,num_classes=10)\n",
    "y_test=to_categorical(y_test,num_classes=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "conv2d_1 (Conv2D)            (None, 24, 24, 6)         156       \n",
      "_________________________________________________________________\n",
      "max_pooling2d_1 (MaxPooling2 (None, 12, 12, 6)         0         \n",
      "_________________________________________________________________\n",
      "conv2d_2 (Conv2D)            (None, 8, 8, 16)          2416      \n",
      "_________________________________________________________________\n",
      "max_pooling2d_2 (MaxPooling2 (None, 4, 4, 16)          0         \n",
      "_________________________________________________________________\n",
      "flatten_1 (Flatten)          (None, 256)               0         \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 120)               30840     \n",
      "_________________________________________________________________\n",
      "dense_2 (Dense)              (None, 84)                10164     \n",
      "_________________________________________________________________\n",
      "dense_3 (Dense)              (None, 10)                850       \n",
      "=================================================================\n",
      "Total params: 44,426\n",
      "Trainable params: 44,426\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "# 构建LeNet-5网络\n",
    "lenet = Sequential()\n",
    "lenet.add(Conv2D(input_shape = (28,28,1), filters=6, kernel_size=(5,5), padding='valid', activation='relu'))\n",
    "lenet.add(MaxPool2D(pool_size=(2,2), strides=2))\n",
    "lenet.add(Conv2D(input_shape=(16,16,8), filters=16, kernel_size=(5,5), padding='valid', activation='relu'))\n",
    "lenet.add(MaxPool2D(pool_size=(2,2), strides=2))\n",
    "lenet.add(Flatten())\n",
    "lenet.add(Dense(120, activation='relu'))\n",
    "lenet.add(Dense(84, activation='relu'))\n",
    "lenet.add(Dense(10, activation='softmax'))\n",
    "lenet.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/20\n",
      "60000/60000 [==============================] - 11s 181us/step - loss: 1.1482 - acc: 0.8318\n",
      "Epoch 2/20\n",
      "60000/60000 [==============================] - 11s 182us/step - loss: 0.1317 - acc: 0.9598\n",
      "Epoch 3/20\n",
      "60000/60000 [==============================] - 11s 178us/step - loss: 0.0980 - acc: 0.9701\n",
      "Epoch 4/20\n",
      "60000/60000 [==============================] - 11s 175us/step - loss: 0.0807 - acc: 0.9753\n",
      "Epoch 5/20\n",
      "60000/60000 [==============================] - 10s 175us/step - loss: 0.0703 - acc: 0.9787\n",
      "Epoch 6/20\n",
      "60000/60000 [==============================] - 11s 179us/step - loss: 0.0626 - acc: 0.9807\n",
      "Epoch 7/20\n",
      "60000/60000 [==============================] - 11s 186us/step - loss: 0.0547 - acc: 0.9825\n",
      "Epoch 8/20\n",
      "60000/60000 [==============================] - 12s 202us/step - loss: 0.0486 - acc: 0.9848\n",
      "Epoch 9/20\n",
      "60000/60000 [==============================] - 12s 193us/step - loss: 0.0445 - acc: 0.9868\n",
      "Epoch 10/20\n",
      "60000/60000 [==============================] - 12s 203us/step - loss: 0.0396 - acc: 0.9878\n",
      "Epoch 11/20\n",
      "60000/60000 [==============================] - 12s 201us/step - loss: 0.0368 - acc: 0.9882\n",
      "Epoch 12/20\n",
      "60000/60000 [==============================] - 13s 216us/step - loss: 0.0336 - acc: 0.9891\n",
      "Epoch 13/20\n",
      "60000/60000 [==============================] - 12s 200us/step - loss: 0.0297 - acc: 0.9907\n",
      "Epoch 14/20\n",
      "60000/60000 [==============================] - 11s 186us/step - loss: 0.0282 - acc: 0.9913\n",
      "Epoch 15/20\n",
      "60000/60000 [==============================] - 11s 184us/step - loss: 0.0251 - acc: 0.9919\n",
      "Epoch 16/20\n",
      "60000/60000 [==============================] - 11s 184us/step - loss: 0.0230 - acc: 0.9924\n",
      "Epoch 17/20\n",
      "60000/60000 [==============================] - 11s 184us/step - loss: 0.0211 - acc: 0.9935\n",
      "Epoch 18/20\n",
      "60000/60000 [==============================] - 11s 184us/step - loss: 0.0192 - acc: 0.9940\n",
      "Epoch 19/20\n",
      "60000/60000 [==============================] - 11s 185us/step - loss: 0.0172 - acc: 0.9948\n",
      "Epoch 20/20\n",
      "60000/60000 [==============================] - 11s 185us/step - loss: 0.0155 - acc: 0.9953\n"
     ]
    }
   ],
   "source": [
    "lenet.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=['accuracy'])\n",
    "lenet_history = lenet.fit(x_train, y_train, batch_size=128, epochs=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10000/10000 [==============================] - 1s 126us/step\n",
      "Testing Loss: 0.06592238205773292\n",
      "Testing Accuracy of: 0.9826\n"
     ]
    }
   ],
   "source": [
    "lenet_score=lenet.evaluate(x_test,y_test)\n",
    "print(\"Testing Loss:\", lenet_score[0])\n",
    "print(\"Testing Accuracy of:\", lenet_score[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "conv2d_3 (Conv2D)            (None, 24, 24, 6)         156       \n",
      "_________________________________________________________________\n",
      "max_pooling2d_3 (MaxPooling2 (None, 12, 12, 6)         0         \n",
      "_________________________________________________________________\n",
      "conv2d_4 (Conv2D)            (None, 8, 8, 16)          2416      \n",
      "_________________________________________________________________\n",
      "max_pooling2d_4 (MaxPooling2 (None, 4, 4, 16)          0         \n",
      "_________________________________________________________________\n",
      "flatten_2 (Flatten)          (None, 256)               0         \n",
      "_________________________________________________________________\n",
      "dense_4 (Dense)              (None, 120)               30840     \n",
      "_________________________________________________________________\n",
      "dropout_1 (Dropout)          (None, 120)               0         \n",
      "_________________________________________________________________\n",
      "dense_5 (Dense)              (None, 84)                10164     \n",
      "_________________________________________________________________\n",
      "dropout_2 (Dropout)          (None, 84)                0         \n",
      "_________________________________________________________________\n",
      "dense_6 (Dense)              (None, 10)                850       \n",
      "=================================================================\n",
      "Total params: 44,426\n",
      "Trainable params: 44,426\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "# 构建LeNet-5网络\n",
    "lenet_drop = Sequential()\n",
    "lenet_drop.add(Conv2D(input_shape = (28,28,1), filters=6, kernel_size=(5,5), padding='valid', activation='relu'))\n",
    "lenet_drop.add(MaxPool2D(pool_size=(2,2), strides=2))\n",
    "lenet_drop.add(Conv2D(input_shape=(16,16,8), filters=16, kernel_size=(5,5), padding='valid', activation='relu'))\n",
    "lenet_drop.add(MaxPool2D(pool_size=(2,2), strides=2))\n",
    "lenet_drop.add(Flatten())\n",
    "lenet_drop.add(Dense(120, activation='relu'))\n",
    "lenet_drop.add(Dropout(0.2))\n",
    "lenet_drop.add(Dense(84, activation='relu'))\n",
    "lenet_drop.add(Dropout(0.2))\n",
    "lenet_drop.add(Dense(10, activation='softmax'))\n",
    "lenet_drop.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/20\n",
      "60000/60000 [==============================] - 11s 186us/step - loss: 14.4106 - acc: 0.1054\n",
      "Epoch 2/20\n",
      "60000/60000 [==============================] - 11s 182us/step - loss: 1.6244 - acc: 0.6266\n",
      "Epoch 3/20\n",
      "60000/60000 [==============================] - 11s 184us/step - loss: 0.3582 - acc: 0.8957\n",
      "Epoch 4/20\n",
      "60000/60000 [==============================] - 11s 182us/step - loss: 0.2443 - acc: 0.9284\n",
      "Epoch 5/20\n",
      "60000/60000 [==============================] - 11s 181us/step - loss: 0.1958 - acc: 0.9431\n",
      "Epoch 6/20\n",
      "60000/60000 [==============================] - 11s 181us/step - loss: 0.1689 - acc: 0.9507\n",
      "Epoch 7/20\n",
      "60000/60000 [==============================] - 11s 182us/step - loss: 0.1504 - acc: 0.9555\n",
      "Epoch 8/20\n",
      "60000/60000 [==============================] - 11s 185us/step - loss: 0.1354 - acc: 0.9602\n",
      "Epoch 9/20\n",
      "60000/60000 [==============================] - 11s 179us/step - loss: 0.1239 - acc: 0.9634\n",
      "Epoch 10/20\n",
      "60000/60000 [==============================] - 11s 182us/step - loss: 0.1177 - acc: 0.9654\n",
      "Epoch 11/20\n",
      "60000/60000 [==============================] - 11s 177us/step - loss: 0.1081 - acc: 0.9678\n",
      "Epoch 12/20\n",
      "60000/60000 [==============================] - 11s 176us/step - loss: 0.1034 - acc: 0.9694\n",
      "Epoch 13/20\n",
      "60000/60000 [==============================] - 11s 176us/step - loss: 0.0975 - acc: 0.9711\n",
      "Epoch 14/20\n",
      "60000/60000 [==============================] - 11s 183us/step - loss: 0.0942 - acc: 0.9719\n",
      "Epoch 15/20\n",
      "60000/60000 [==============================] - 11s 179us/step - loss: 0.0884 - acc: 0.9740\n",
      "Epoch 16/20\n",
      "60000/60000 [==============================] - 11s 186us/step - loss: 0.0828 - acc: 0.9753\n",
      "Epoch 17/20\n",
      "60000/60000 [==============================] - 11s 191us/step - loss: 0.0824 - acc: 0.9757\n",
      "Epoch 18/20\n",
      "60000/60000 [==============================] - 11s 183us/step - loss: 0.0779 - acc: 0.9763\n",
      "Epoch 19/20\n",
      "60000/60000 [==============================] - 11s 181us/step - loss: 0.0757 - acc: 0.9765\n",
      "Epoch 20/20\n",
      "60000/60000 [==============================] - 11s 181us/step - loss: 0.0735 - acc: 0.9776\n"
     ]
    }
   ],
   "source": [
    "lenet_drop.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=['accuracy'])\n",
    "lenet_drop_history = lenet_drop.fit(x_train, y_train, batch_size=128, epochs=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10000/10000 [==============================] - 1s 131us/step\n",
      "Testing Loss: 0.05491561537194575\n",
      "Testing Accuracy of: 0.9841\n"
     ]
    }
   ],
   "source": [
    "lenet_drop_score=lenet_drop.evaluate(x_test,y_test)\n",
    "print(\"Testing Loss:\", lenet_drop_score[0])\n",
    "print(\"Testing Accuracy of:\", lenet_drop_score[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['loss', 'acc'])\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDc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DUkEpETTzyRc889l6OPPprBgwczevToFn/M77vvPu68804OO+wwDj30UP74x6Dz4Oyzz+b6669nyJAhzR4svueee7jiiiuorq5mwYIFXH311TQ0NDB27FgGDx7MkCFDuPTSS+nZsyc333wzgwYNorq6mrKyMr785S+36fvvKAp6z+Kwa+jP7j7IzAYDM4HUuZz9gPeAoe6+srn11NbW+i7fmOaXQ6HqQDjrt7u2vEgH8/rrrzNw4MCow5Aiy/a5m9k8d69tadmiFZ1z91eAPqnXZrYUqC3oWUMQnDmkriERkZwK1jVkZvcDLwAHmdlyM/tGodpqVmUfdQ2JiDSjkGcNndPC9P6FaruJij5Qp0QgIpJL576yGKCyCrbVqcyEiEgOMUgEKjMhItKczp8IKlJlJpQIRESy6fyJoDJ1UZkSgUixFLsMdTHaz9ezzz7L7Nmzs067++67ueSSS4ocUctikAjUNSTSGbS2DHV9fX0bRpNbc4mgver8iaBCewQiUSpGGep//etfjVcv//CHP2wc/+yzz3LssccycuRIDjnkEABuvPFGBg0axKBBg7j55psb4zn44IMZM2YMAwcOZPTo0WzaFJxgMnPmTIYMGcLgwYM5//zzG4vg9e/fnw8+CC6Dmjt3LscffzxLly5lypQp3HTTTdTU1DSWushm6dKlnHDCCVRXVzNixAjefTeow/nQQw8xaNAgDjvsMD73uc8B8OqrrzJ06FBqamqorq5m8eLFrftQMhTtgrLIlJQFZSaUCCSOnrgSVr7Stuv81GD48s/ymrVYZagnTZrERRddxLhx45g8eXKTafPnz2fhwoUMGDCAefPmMXXqVObMmYO7M2zYMI477jh69erFG2+8wZ133snw4cM5//zz+d///V8uueQSJkyYwMyZMznwwAMZN24ct912G5dddlnW99u/f38uvPBCKisrufzyy5vdNt/61rcYP34848eP56677uLSSy9l+vTpXHvttTz55JPss88+jeWyp0yZwqRJkxgzZgzbtm2joaEhr+2fr86/RwBB95AqkIoUXXoZ6sMPP5xFixY1/jfbUhnqmpoaLrjgAt5///0W2/nb3/7GOecEly6dd955TaYNHTqUAQMGADBr1iy++tWvUlFR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pqj3Xz+1gvpC8Aid1+ebWKU269Voj5a3VYPgrNa3iQ4o+AH4bhrCb70AOUEXQpvAS8C+xcxts8SdBO8DCwIHycDFwIXhvNcArxKcBbE34Fjihjf/mG7/wxjSG2/9PgMmBxu31eA2iJ/vhUEP+y7p42LbPsRJKT3ge0E/dTfIDjmNBNYDDwN7BHOWwv8Om3Z88Pv4VvA14sY31sE/eup72DqLLq9gceb+y4UKb57w+/WywQ/7ntlxhe+3ulvvRjxhePvTn3n0uYt+vZr64dKTIiIxFxn6RoSEZFdpEQgIhJzSgQiIjGnRCAiEnNKBCIiMadEIFJgYWXUP0cdh0guSgQiIjGnRCASMrOxZvZiWEf+V2ZWYmZ1ZnaTBfeRmGlmVeG8NWb297Ta/r3C8f9mZk+Hxe/mm9lnwtVXmtnD4f0A7itW5VuRfCgRiABmNhA4Cxju7jVAAzCG4Irmue5+KPBX4Jpwkd8A33P3aoKrYVPj7wMme1D87hiCq1MhqDh7GXAIwdWnwwv+pkTyVBp1ACLtxAjgCOCl8J/1bgRF45LsKDD2W+APZrY70NPd/xqOvwd4KKwxs4+7TwNw9y0A4fpe9LA+TXhnq/7ArMK/LZGWKRGIBAy4x92vajLS7L8y5tvVmixb04Yb0N+etCPqGhIJzARGm1kfaLz/8KcJ/kZGh/OcC8xy9/XAR2Z2bDj+POCvHtx9brmZnRauo6uZdS/quxDZBfqvRARw99fM7IcEd5ZKEFSd/A9gIzA0nLaa4DgCBGWmp4Q/9G8DXw/Hnwf8ysyuDddxRhHfhsguUfVRkWaYWZ27V0Ydh0ghqWtIRCTmtEcgIhJz2iMQEYk5JQIRkZhTIhARiTklAhGRmFMiEBGJuf8PLvk5Wzhc3KkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(lenet_history.history.keys())\n",
    "# summarize history for accuracy\n",
    "plt.plot(lenet_history.history['loss'])\n",
    "plt.plot(lenet_drop_history.history['loss'])\n",
    "plt.title('model accuracy')\n",
    "plt.ylabel('loss')\n",
    "plt.xlabel('epoch')\n",
    "plt.legend(['lenet loss','lenet dropout loss'], loc='upper right')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
